// xdoor.txt - replaces the door script with a non-door version (unopenable door).
// - Will read an sdf and if matched to get_memory_cell(0), will give a journal,
// if not will kill party...
//
// Memory Cells - 0 = door number.
//

beginterrainscript;

variables;

short choice;

body;

beginstate INIT_STATE;
break;

beginstate START_STATE;
break;

beginstate SEARCH_STATE;
	message_dialog("The door seems to be just a door.", "If you open it, maybe it will reveal it's secrets to you.");
break;

beginstate BLOCK_MOVE_STATE;
	play_sound(58);
	if (get_flag(50, 11) > 0) {
		message_dialog("There's nothing behind the door, so you close it.", "");
		play_sound(-59);
		end();
	}
	if (get_flag(50, 7) == get_memory_cell(0)) {
		reset_dialog();
		add_dialog_str(0, "As you open the door, you see a journal on a shelf.", 0);
		add_dialog_str(1, "You grab at it as it starts to slip and fall.", 0);
		add_dialog_str(2, "Your aim is true and you snaggle the journal out of the air.", 0);
		add_dialog_str(3, "With the journal safely in your hands, you close the door.", 0);
		add_dialog_choice(0, "Ok");
		choice = run_dialog(0);
		play_sound(-59);
		set_flag(50, 11, 1);
		reward_give(460);
		award_party_xp(100, 25);
	}
	else {
		message_dialog("In your haste to see what is behind the door, you step off the cliff running behind the manor.", "What a trap you think as you fall to your death.");
		kill_char(1000, 2, 0);
	}
break;

beginstate UNLOCK_SPELL_STATE;
	print_str_color("Your unlock door spell fizzles.", 2);
break;

beginstate DISPEL_BARRIER_STATE;
	print_str_color("Dispel Barrier: The spell fails to affect this door.", 2);
break;
